"""meiduo_mall URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include



# from django.http import HttpResponse
# # 为了记录日志，定义一个视图函数
# def test(request):
#
#     # 1.导入系统日志
#     import logging
#     # 2.根据配置信息，创建日志器
#     logger=logging.getLogger('django')
#     # 3.记录日志
#     # 3.1如果有警告
#     logger.warning('日志警告')
#     # 3.2如果有错误
#     logger.error('日志error')
#     # 3.3如果记录信息
#     logger.info('记录日志信息')
#
#     return HttpResponse('test')



# 注册转换器并告知系统
from django.urls import register_converter
from utils.converters import UsernameConverter, UUIDConverter

# 1.参数1： 转换器类
# 2.参数2： 转换器的别名
register_converter(UsernameConverter,'uc')
register_converter(UUIDConverter,'uuid')



urlpatterns = [
    path('admin/', admin.site.urls),

    # path('test/',test),

    # 导入 apps.users下的urls
    # 注意： 要使用apps.***
    # 因为 子应用 在apps包下
    path('',include('apps.users.urls')),
    path('',include('apps.verifications.urls')),
    path('',include('apps.oauth.urls')),
    path('',include('apps.areas.urls')),
    path('',include('apps.goods.urls')),
    path('',include('apps.carts.urls')),
    path('',include('apps.orders.urls')),
    path('',include('apps.payment.urls')),

    # 项目2的url都是以meiduo_admin开头，所以只要是meiduo_admin开头的，都到meiduo_admin子应用匹配
    path('meiduo_admin/',include('apps.meiduo_admin.urls')),
]
